{extend name="index/index" /}
{block name="main"}
{js href="/static/index/js/jquery.min.js"}
<!-- Start right content -->

<!---->
<div class="content-page">

    <div class="content">

        <div class="page-heading">
            <h1><i class='fa fa-table'></i>文章管理</h1>
            <h3>文章列表</h3></div>

        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>Sortable</strong> Table</h2>

                    </div>
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>文章名</th>
                                    <th>发表时间</th>
                                    <th>所属栏目</th>
                                    <th>操作</th>
                                    {volist name='list'  id='v' }
                                    <tr>
                                        <td>{$v.art_id}</td>
                                        <td>{$v.artname}</td>
                                        <td>{$v.arttime}</td>
                                        <td>{$v.column_id}</td>
                                        <td>
                                            <a href="{:url('admin/article/details',['id'=>$v['art_id']])}" class="btn btn-info">详细信息</a>
                                            <a href="{:url('admin/article/edit',['id'=>$v['art_id']])}" class="btn btn-primary">修改</a>
                                            <button  data-id='{$v.art_id}'  class="btn btn-danger delArt" >删除</button>
                                        </td>
                                    </tr>
                                    {/volist}

                                </tr>
                                </thead>

                                <tbody>


                                </tbody>
                            </table>
                            {$list->render()}
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Footer Start -->

        <!-- Footer End -->
    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>
<!-- End right content -->

<script type="text/javascript">


    $(function () {
            // 触发删除用户
            $('.delArt').click(function () {
                var id = $(this).attr('data-id');
                    // alert(dataid);

                if (confirm('您确定要 [ 删 除 ] 该文章吗?')) {
                    var obj = $(this).parents('tr');

                    var info = 'artid'+'='+id;


                    $.ajax({
                        type: 'post',
                        url: '/admin/article/delete',
                        data: info,
                        dataType : 'json',
                        success : function (data){

                            if (data.status) {
                                toastr.success('删除成功');
                                obj.remove();
                            } else {
                                toastr.error('删除失败');
                            }
                            // alert('执行成功');
                        },
                        error : function () {
                            alert('执行失败');
                        }
                    });
                }
        });
    });

    toastr.options = {
    closeButton: true,// 是否显示关闭按钮
    progressBar: true,// 实现显示计时条
    timeOut: "2000",// 自动关闭时间
    positionClass: "toast-top-right"// 提示位置
    // positionClass: "toast-top-full-width"// 提示位置
    // toast-top-full-width 顶端，宽度铺满整个屏幕
    // toast-top-right  顶端右边
    };

</script>

{/block}